package com.ricoh.paypal.util;import javax.servlet.http.HttpServletRequest;/** * @author xionglijing * @date 2021/9/26 17:21 * @description */public class URLUtils{    public static String getBaseURl(HttpServletRequest request) {        String scheme = request.getScheme();        String serverName = request.getServerName();        int serverPort = request.getServerPort();        String contextPath = request.getContextPath();        StringBuffer url =  new StringBuffer();        url.append(scheme).append("://").append(serverName);        if ((serverPort != 80) && (serverPort != 443)) {            url.append(":").append(serverPort);        }        url.append(contextPath);        if(url.toString().endsWith("/")){            url.append("/");        }        return url.toString();    }}